<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教师信息修改</title>
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
</head>
<body>
    <br><br>
<div style="margin-left: 70px;">
    {if $Think.session.teacher.img}
    <img id="test1"  src="/uploads/{$Think.session.teacher.img}" alt="" width="150px" height="150px"><br>
    {else/}
    <img id="test1"  src="/static/img/头像默认.png" alt="" width="150px" height="150px"><br>
    {/if}
    <p style="color: #666;">(点击头像上传新的头像)</p>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">姓名:</label>
    <div class="layui-form-mid">
        {$teacher.realname}
    </div>
    <div class="layui-input-inline">
        <input type="text" name="realname" id="realname" value="{$teacher.realname}" class="layui-input">
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">邮箱:</label>
    <div class="layui-form-mid">
        {$teacher.email}
    </div>
    <div class="layui-input-inline">
        <input type="text" name="email" id="email" value="{$teacher.email}" class="layui-input">
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">手机号码:</label>
    <div class="layui-form-mid">
        {$teacher.tel}
    </div>
    <div class="layui-input-inline">
        <input type="text" name="tel" id="tel" value="{$teacher.tel}" class="layui-input">
    </div>
</div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属教室:</label>
        <div class="layui-form-text">
            {foreach $labs as $lab}
            {$lab}
            {/foreach}
        </div>
    </div>
    <div class="layui-form-item">
            <button class="layui-btn" id="xiugai" style="margin-left: 30px;">修改信息</button>
            <button class="layui-btn" id="queding" style="margin-left: 30px;">确定修改</button>
    </div>
</body>
<style>
    #test1:hover{
        cursor: pointer;
        opacity: 0.7;
    }
</style>
<script>
    $("#queding").hide();
    $(".layui-input-inline").css('display','none');
    $("#xiugai").click(function () {
        $(".layui-input-inline").fadeIn();
        $(".layui-form-mid").hide();
        $(".layui-btn").html("确认修改");
        $(this).hide();
        $("#queding").show();
    });
    $("#queding").click(function () {
        $.post(
            "",
            {
                realname:$("#realname").val(),
                tel:$("#tel").val(),
                email:$("#email").val()
            },
            function (data) {
                if (data.statu==200){
                    alert(data.msg);
                } else{
                    alert(data.msg);
                }
            }
        )
    });
    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: '{:url('teacher_img_uploads')}' //上传接口
            ,done: function(res){
                //上传完毕回调
                if (res.statu==200){
                    $('#test1').attr('src','/uploads/'+res.file)
                    layer.msg(res.msg);
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });
</script>
</html>